package cn.wolfcode.service.impl;

import cn.wolfcode.domain.ZmessageReply;
import cn.wolfcode.mapper.ZmessageReplyMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.IZmessageReplyService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ZmessageReplyServiceImpl implements IZmessageReplyService {

    @Autowired
    private ZmessageReplyMapper zmessageReplyMapper;


    @Override
    public void save(ZmessageReply zmessageReply) {
        zmessageReplyMapper.insert(zmessageReply);
    }

    @Override
    public void delete(Long id) {
        zmessageReplyMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(ZmessageReply zmessageReply) {
        zmessageReplyMapper.updateByPrimaryKey(zmessageReply);
    }

    @Override
    public ZmessageReply get(Long id) {
        return zmessageReplyMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<ZmessageReply> listAll() {
        return zmessageReplyMapper.selectAll();
    }

    @Override
    public PageInfo<ZmessageReply> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize()); //对下一句sql进行自动分页
        List<ZmessageReply> zmessageReplys = zmessageReplyMapper.selectForList(qo); //里面不需要自己写limit
        return new PageInfo<ZmessageReply>(zmessageReplys);
    }

    @Override
    public List<ZmessageReply> selectById(Long id) {
        return zmessageReplyMapper.selectById(id);
    }
}
